package com.aaa.system.controller;

import com.aaa.common.entity.AclUser;
import com.aaa.common.vo.Result;
import com.aaa.security.annotation.RequiresPermissions;
import com.aaa.system.service.AclUserService;
import com.aaa.system.vo.UserVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/user")
public class AclUserController {
    @Autowired
    private AclUserService userService;

    @GetMapping("/getByName/{username}")
    public Result<AclUser> getName(@PathVariable String username){
        return userService.findByName(username);
    }

    @GetMapping("list")
    @RequiresPermissions(value="user:list")
    public String list(){
        System.out.println("~~~~~~~~用户查询~~~~~~~~~");
        return "用户查询";
    }
    @GetMapping("deleteUserById/{id}")
    @RequiresPermissions(value="user:remove")
    public Result<Void> remove(@PathVariable String id){
        System.out.println("~~~~~~~~用户删除~~~~~~~~~");
        return new Result<>(2000,"删除用户");
    }
    @GetMapping("info")
    public Result<AclUser>info(){
        return userService.findUserinfo();
    }

    @PostMapping("getUserByPage/{current}/{pageSize}")
    public Result<IPage<AclUser>>getUserByPage(@PathVariable(required = true) Integer current, @PathVariable(required = true) Integer pageSize,
                                               @RequestBody UserVo userVo){
        return userService.findByConditionPage(current,pageSize,userVo);
    }
}
